const defaultDataSource1 = [
  {
    title: '是',
    value: '1',
  },
  {
    title: '否',
    value: '2',
  },
];

const defaultDataSource2 = [
  {
    title: '是',
    value: '1',
  },
  {
    title: '否',
    value: '2',
  },
  {
    title: '不适用',
    value: '3',
  },
];

const defaultDataSource3 = [
  {
    title: '固定',
    value: '1',
  },
  {
    title: '浮动',
    value: '2',
  },
];

export default [
  {
    title: '利率条件',
    key: 'a',
    dataSource: defaultDataSource1,
    onChange: (e, form) => {
      form.resetFields(['a1', 'a2', 'a3', 'a4']);
    },
    initialValue: (form, e) => {
      const { a1, a2, a3, a4 } = form.getFieldsValue();
      if (a1 == '1' && (a4 == '1' || a4 == '3')) return '2';
      if (a1 == '1' && a4 == '2') return '1';
      if (a1 == '2' && a2 == '2' && a3 == '2' && a4 == '2') return '1';
      if (a1 == '2' && a2 == '2' && a3 == '2' && (a4 == '1' || a4 == '3')) return '2';
      if (a1 == '2' && a2 == '2' && (a3 == '1' || a3 == '3')) return '1';
      if (a1 == '2' && a2 == '1' && a4 == '2') return '1';
      if (a1 == '2' && a2 == '1' && (a4 == '1' || a4 == '3')) return '2';
      if (a1 == '2' && a4 == '2') return '1';
      return undefined;
    },
    children: [
      {
        title: '利率类型',
        key: 'a1',
        disabled: () => false,
        onChange: (e, form) => {
          //   固定 || 空 时 清空A2、A3数据
          if (e == '1' || e == '3') form?.resetFields(['a2', 'a3']);
        },
        dataSource: defaultDataSource3,
      },
      {
        title: '重设期间指标利率是否与重设期间一致',
        key: 'a2',
        disabled: (form) => {
          const { a1 } = form.getFieldsValue();
          // a1为浮动时可以下拉
          if (a1 == '2') return false;
          return true;
        },
        onChange: (e, form) => {
          //   是 || 空 时 清空A3数据
          if (e == '1' || e == '3') form?.resetFields(['a3']);
        },
        dataSource: defaultDataSource1,
      },
      {
        title: '未折现的合同现金流量是否显著不同于未折现的基准现金流量',
        key: 'a3',
        disabled: (form) => {
          const { a2 } = form.getFieldsValue();
          // a2为否时可以下拉
          if (a2 == '2') return false;
          return true;
        },
        dataSource: defaultDataSource2,
      },
      {
        title: '若有递延付息条款，递延未付利息仍加计合理的利息',
        key: 'a4',
        dataSource: defaultDataSource2,
      },
    ],
  },
  {
    title: '混合合同',
    key: 'b',
    dataSource: defaultDataSource1,
    initialValue: (form) => {
      const { b1, b2, b3 } = form.getFieldsValue();
      if (b1 == '1') {
        if (b3 == '1') return '1';
        if (b3 == '2') return '2';
      }
      if (b1 == '2') return '2';
      return undefined;
    },
    onChange: (e, form) => {
      form.resetFields(['b1', 'b2', 'b3']);
    },
    children: [
      {
        title: '是否有隐含嵌入性合同在內',
        key: 'b1',
        dataSource: defaultDataSource1,
        onChange: (e, form) => {
          //   否 || 空 时 清空b2、b3数据
          if (e == '2' || e == '3') form?.resetFields(['b2', 'b3']);
        },
      },
      {
        title: '嵌入要素性质',
        key: 'b2',
        disabled: (form) => {
          const { b1 } = form.getFieldsValue();
          // b1为是时可以下拉
          if (b1 == '1') return false;
          return true;
        },
        dataSource: [
          {
            title: '股价',
            value: '1',
          },
          {
            title: '信用',
            value: '2',
          },
          {
            title: '利率',
            value: '3',
          },
          {
            title: '外汇',
            value: '4',
          },
          {
            title: '参数表',
            value: '5',
          },
          {
            title: '通货膨胀',
            value: '6',
          },
          {
            title: '其他',
            value: '7',
          },
          {
            title: '不适用',
            value: '8',
          },
        ],
      },
      {
        title: '是否具有杠杆性',
        key: 'b3',
        disabled: (form) => {
          const { b1 } = form.getFieldsValue();
          // b1为是时可以下拉
          if (b1 == '1') return false;
          return true;
        },
        dataSource: defaultDataSource1,
      },
    ],
  },
  {
    title: '合同连接工具',
    key: 'c',
    dataSource: defaultDataSource1,
    onChange: (e, form) => {
      form.resetFields(['c1', 'c2', 'c3', 'c4']);
    },
    initialValue: (form) => {
      const { c1, c2, c3, c4 } = form.getFieldsValue();
      if (c1 == '1' && c2 == '1' && c3 == '1' && c4 == '1') return '2';
      if (c1 == '1' && c2 == '1' && c3 == '1' && c4 == '2') return '1';
      if (c1 == '1' && c2 == '1' && c3 == '3' && c4 != undefined) return '1';
      if (c1 == '1' && c2 == '1' && c3 == '2') return '1';
      if (c1 == '1' && c2 == '3' && (c3 == '1' || c3 == '3') && c4 != undefined) return '1';
      if (c1 == '1' && c2 == '3' && c3 == '2') return '1';
      if (c1 == '1' && c2 == '2') return '1';
      if (c1 == '2') return '2';

      return undefined;
    },
    children: [
      {
        title: '是否为分级证券',
        key: 'c1',
        dataSource: defaultDataSource1,
        onChange: (e, form) => {
          //   否 || 空 时 清空c2、c3、c4数据
          if (e == '2' || e == '3') form?.resetFields(['c2', 'c3', 'c4']);
        },
      },
      {
        title: '分级证券合同条款中发行人仅支付本金与未偿付本金金额之利息',
        key: 'c2',
        dataSource: defaultDataSource2,
        onChange: (e, form) => {
          //   否 || 空 时 清空c3、c4数据
          if (e == '2' || e == undefined) form?.resetFields(['c3', 'c4']);
        },
        disabled: (form) => {
          const { c1 } = form.getFieldsValue();
          // c1为是时可以下拉
          if (c1 == '1') return false;
          return true;
        },
      },
      {
        title: '资产池的所有金融工具是否均满足、且一直满足仅支付本金与利息',
        key: 'c3',
        dataSource: defaultDataSource2,
        onChange: (e, form) => {
          //   否 || 空 时 清空c4数据
          if (e == '2' || e == undefined) form?.resetFields(['c4']);
        },
        disabled: (form) => {
          const { c2 } = form.getFieldsValue();
          // C1为“是”，且C2为“是”或“不适用”时，可选下拉数据
          if (c2 == '1' || c2 == '3') return false;
          return true;
        },
      },
      {
        title: '购买该分级信用风险低于整体群组下的信用风险',
        key: 'c4',
        dataSource: defaultDataSource1,
        disabled: (form) => {
          const { c3 } = form.getFieldsValue();
          //C1为“是”，且C2为“是”或“不适用”，且C3为“是”或“不适用”时，可选下拉数据
          if (c3 == '1' || c3 == '3') return false;
          return true;
        },
      },
    ],
  },
  {
    title: '无追索权',
    key: 'd',
    dataSource: defaultDataSource1,
    onChange: (e, form) => {
      form.resetFields(['d1', 'd2']);
    },
    initialValue: (form) => {
      const { d1, d2 } = form.getFieldsValue();
      if (d1 == '1') {
        if (d2 == '2') return '1';
        if (d2 == '1') return '2';
      }
      if (d1 == '2') return '2';
      return undefined;
    },
    children: [
      {
        title: '是否有债权人的索偿要求仅限于债务人的特定资产或产生于特定资产的现金流量的情况',
        key: 'd1',
        dataSource: defaultDataSource1,
        onChange: (e, form) => {
          //   否 || 空 时 清空c4数据
          if (e == '2' || e == undefined) form?.resetFields(['d2']);
        },
      },
      {
        title: '经评估 (“看穿”) 特定的标的资产或现金流量，合同现金流量是否为对本金及未偿付本金金额之利息的支付',
        key: 'd2',
        dataSource: defaultDataSource1,
        disabled: (form) => {
          const { d1 } = form.getFieldsValue();
          //d1为“是” 可选下拉数据
          if (d1 == '1') return false;
          return true;
        },
      },
    ],
  },
  {
    title: '提前偿还',
    key: 'e',
    dataSource: defaultDataSource1,
    onChange: (e, form) => {
      form.resetFields(['e1', 'e2', 'e3']);
    },
    initialValue: (form) => {
      const { e1, e2, e3 } = form.getFieldsValue();
      if (e1 == '1') {
        if (e2 != undefined) {
          if (e3 == '1') return '2';
          if (e3 == '2') return '1';
        }
      }
      if (e1 == '2') return '2';
      return undefined;
    },
    children: [
      {
        title: '是否可选择提前还款',
        key: 'e1',
        dataSource: defaultDataSource1,
        onChange: (e, form) => {
          //   否 || 空 时 清空e2,e3数据
          if (e == '2' || e == undefined) form?.resetFields(['e2', 'e3']);
        },
      },
      {
        title: '是否有提前还款的额外补偿',
        key: 'e2',
        dataSource: defaultDataSource1,
        disabled: (form) => {
          const { e1 } = form.getFieldsValue();
          //e1为“是” 可选下拉数据
          if (e1 == '1') return false;
          return true;
        },
      },
      {
        title: '提前还款的金额 (含额外补偿) 几乎代表尚未支付之本金及未偿付本金金额之利息',
        key: 'e3',
        dataSource: defaultDataSource1,
        disabled: (form) => {
          const { e1 } = form.getFieldsValue();
          //e1为“是” 可选下拉数据
          if (e1 == '1') return false;
          return true;
        },
      },
    ],
  },
  {
    title: '展期',
    key: 'f',
    dataSource: defaultDataSource1,
    onChange: (e, form) => {
      form.resetFields(['f1', 'f2', 'f3']);
    },
    initialValue: (form) => {
      const { f1, f2, f3, f } = form.getFieldsValue();

      if (f1 == '1') {
        if (f2 != undefined) {
          if (f3 == '1') return '2';
          if (f3 == '2') return '1';
        }
      }
      if (f1 == '2') return '2';
      return undefined;
    },
    children: [
      {
        title: '是否可选择延期',
        key: 'f1',
        dataSource: defaultDataSource1,
        onChange: (e, form) => {
          //   否 || 空 时 清空f2,f3数据
          if (e == '2' || e == undefined) form?.resetFields(['f2', 'f3']);
        },
      },
      {
        title: '是否有展期的额外补偿',
        key: 'f2',
        dataSource: defaultDataSource1,
        disabled: (form) => {
          const { f1 } = form.getFieldsValue();
          //f1为“是” 可选下拉数据
          if (f1 == '1') return false;
          return true;
        },
      },
      {
        title: '资产池的所有金融工具是否均满足、且一直满足仅支付本金与利息',
        key: 'f3',
        dataSource: defaultDataSource1,
        disabled: (form) => {
          const { f1 } = form.getFieldsValue();
          //f1为“是” 可选下拉数据
          if (f1 == '1') return false;
          return true;
        },
      },
    ],
  },
];
